library(ArchR)
## Loading required package: ggplot2
## Loading required package: SummarizedExperiment
## Loading required package: GenomicRanges
## Loading required package: stats4
## Loading required package: BiocGenerics
## Loading required package: parallel
##
## Attaching package: 'BiocGenerics'
## The following objects are masked from 'package:parallel':
##
## clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
## clusterExport, clusterMap, parApply, parCapply, parLapply,
## parLapplyLB, parRapply, parSapply, parSapplyLB
## The following objects are masked from 'package:stats':
##
## IQR, mad, sd, var, xtabs
## The following objects are masked from 'package:base':
##
## anyDuplicated, append, as.data.frame, basename, cbind, colnames,
## dirname, do.call, duplicated, eval, evalq, Filter, Find, get, grep,
## grepl, intersect, is.unsorted, lapply, Map, mapply, match, mget,
## order, paste, pmax, pmax.int, pmin, pmin.int, Position, rank,
## rbind, Reduce, rownames, sapply, setdiff, sort, table, tapply,
## union, unique, unsplit, which, which.max, which.min
## Loading required package: S4Vectors
##
## Attaching package: 'S4Vectors'
## The following object is masked from 'package:base':
##
## expand.grid
## Loading required package: IRanges
## Loading required package: GenomeInfoDb
## Loading required package: Biobase
## Welcome to Bioconductor
##
## Vignettes contain introductory material; view with
## 'browseVignettes()'. To cite Bioconductor, see
## 'citation("Biobase")', and for packages 'citation("pkgname")'.
## Loading required package: DelayedArray
## Loading required package: matrixStats
##
## Attaching package: 'matrixStats'
## The following objects are masked from 'package:Biobase':
##
## anyMissing, rowMedians
## Loading required package: BiocParallel
##
## Attaching package: 'DelayedArray'
## The following objects are masked from 'package:matrixStats':
##
## colMaxs, colMins, colRanges, rowMaxs, rowMins, rowRanges
## The following objects are masked from 'package:base':
##
## aperm, apply, rowsum
## Loading required package: data.table
##
## Attaching package: 'data.table'
## The following object is masked from 'package:SummarizedExperiment':
##
## shift
## The following object is masked from 'package:GenomicRanges':
##
## shift
## The following object is masked from 'package:IRanges':
##
## shift
## The following objects are masked from 'package:S4Vectors':
##
## first, second
## Loading required package: Matrix
##
## Attaching package: 'Matrix'
## The following object is masked from 'package:S4Vectors':
##
## expand
## Loading required package: rhdf5
## Loading required package: magrittr
archProj <- loadArchRProject("../data/scATAC/archR_subHybridClusters/",
showLogo = FALSE)
## Successfully loaded ArchRProject!
plotEmbedding(ArchRProj = archProj, colorBy = "cellColData",
name = "predAnn", embedding = "UMAP_cor")
## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-1051127c59bbd-Date-2021-10-22_Time-11-12-16.log
## If there is an issue, please report to github with logFile!
## Getting UMAP Embedding
## ColorBy = cellColData
## Plotting Embedding
## 1
## ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-1051127c59bbd-Date-2021-10-22_Time-11-12-16.log

archProj <- addMotifAnnotations(ArchRProj = archProj,
motifSet = "cisbp",
name = "Motif",
force=TRUE)
## No methods found in package 'IRanges' for request: 'score' when loading 'TFBSTools'
## ArchR logging to : ArchRLogs/ArchR-addMotifAnnotations-105111e73a9b1-Date-2021-10-22_Time-11-12-19.log
## If there is an issue, please report to github with logFile!
## peakAnnotation name already exists! Overriding.
## 2021-10-22 11:12:23 : Gettting Motif Set, Species : Mus musculus, 0.002 mins elapsed.
## Using version 2 motifs!
## 2021-10-22 11:12:26 : Finding Motif Positions with motifmatchr!, 0.042 mins elapsed.
## 2021-10-22 11:15:28 : Creating Motif Overlap Matrix, 3.084 mins elapsed.
## 2021-10-22 11:15:32 : Finished Getting Motif Info!, 3.147 mins elapsed.
## ArchR logging successful to : ArchRLogs/ArchR-addMotifAnnotations-105111e73a9b1-Date-2021-10-22_Time-11-12-19.log
## get ArchR peak markers for motif enrichment
markerPeaks_subHybrid <- getMarkerFeatures(
ArchRProj = archProj,
useMatrix = "PeakMatrix",
groupBy = "predAnn",
bias = c("TSSEnrichment", "log10(nFrags)"),
testMethod = "wilcoxon")
## ArchR logging to : ArchRLogs/ArchR-getMarkerFeatures-105113b89b315-Date-2021-10-22_Time-11-15-36.log
## If there is an issue, please report to github with logFile!
## MatrixClass = Sparse.Integer.Matrix
## 2021-10-22 11:15:36 : Matching Known Biases, 0.004 mins elapsed.
## 2021-10-22 11:15:37 : Computing Pairwise Tests (1 of 5), 0.026 mins elapsed.
## 2021-10-22 11:16:00 : Computing Pairwise Tests (2 of 5), 0.399 mins elapsed.
## 2021-10-22 11:16:22 : Computing Pairwise Tests (3 of 5), 0.769 mins elapsed.
## 2021-10-22 11:16:43 : Computing Pairwise Tests (4 of 5), 1.115 mins elapsed.
## 2021-10-22 11:17:03 : Computing Pairwise Tests (5 of 5), 1.459 mins elapsed.
## ###########
## 2021-10-22 11:17:26 : Completed Pairwise Tests, 1.837 mins elapsed.
## ###########
## ArchR logging successful to : ArchRLogs/ArchR-getMarkerFeatures-105113b89b315-Date-2021-10-22_Time-11-15-36.log
peakMarkers_subHybrid <- getMarkers(markerPeaks_subHybrid,
cutOff = "FDR <= 0.01 & Log2FC >= 1.25",
returnGR = TRUE)
heatmapMarkerPeaks <- plotMarkerHeatmap(
seMarker = markerPeaks_subHybrid,
cutOff = "FDR <= 0.01 & Log2FC >= 1.25",
transpose = TRUE
)
## ArchR logging to : ArchRLogs/ArchR-plotMarkerHeatmap-105114d4c463c-Date-2021-10-22_Time-11-17-29.log
## If there is an issue, please report to github with logFile!
## Identified 20694 markers!
## Preparing Main Heatmap..
## ArchR logging successful to : ArchRLogs/ArchR-plotMarkerHeatmap-105114d4c463c-Date-2021-10-22_Time-11-17-29.log
ComplexHeatmap::draw(heatmapMarkerPeaks, heatmap_legend_side = "bot", annotation_legend_side = "bot")

Check accessibility of Egfr target genes
egfrTargetDf <- read.csv("../data/genesTargets/egfr_targets_unfiltered.csv")
pCluster <- plotEmbedding(ArchRProj = archProj,
colorBy = "cellColData",
name = "predAnn",
embedding = "UMAP_cor")
## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-105113423f8f7-Date-2021-10-22_Time-11-17-36.log
## If there is an issue, please report to github with logFile!
## Getting UMAP Embedding
## ColorBy = cellColData
## Plotting Embedding
## 1
## ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-105113423f8f7-Date-2021-10-22_Time-11-17-36.log
pCluster

allGenes <- unname(unique(mcols(archProj@geneAnnotation$genes)$symbol))
egfrTargets <- intersect(as.character(egfrTargetDf$target), allGenes)
## get peak count matrix
ArrowFiles <- getArrowFiles(archProj)
featureDF <- ArchR:::.getFeatureDF(head(ArrowFiles, 2), "PeakMatrix")
peakMat <- ArchR:::.getPartialMatrix(ArrowFiles,
featureDF = featureDF, threads = 1, useMatrix = "PeakMatrix",
cellNames = rownames(archProj@cellColData), progress = FALSE)
## 2021-10-22 11:17:38 : Getting Partial Matrix 1 of 6, 0 mins elapsed.
## 2021-10-22 11:17:46 : Getting Partial Matrix 2 of 6, 0.141 mins elapsed.
## 2021-10-22 11:17:49 : Getting Partial Matrix 3 of 6, 0.187 mins elapsed.
## 2021-10-22 11:17:52 : Getting Partial Matrix 4 of 6, 0.249 mins elapsed.
## 2021-10-22 11:17:57 : Getting Partial Matrix 5 of 6, 0.318 mins elapsed.
## 2021-10-22 11:18:00 : Getting Partial Matrix 6 of 6, 0.368 mins elapsed.
## 2021-10-22 11:18:08 : Successfully Created Partial Matrix, 0.504 mins elapsed.
## for each gene, get the peak closest to TSS
peakGR <- archProj@peakSet
tssPeaks <- c()
for(gg in 1:length(egfrTargets)){
curGene <- egfrTargets[gg]
curID <- which(mcols(peakGR)$nearestGene == curGene)
if(length(curID) > 0 ){
curTSSPeak <- curID[which.min(mcols(peakGR)$distToTSS[curID])]
tssPeaks[gg] <- curTSSPeak
} else {
tssPeaks[gg] <- NA
next
}
}
egfrTargets <- egfrTargets[!is.na(tssPeaks)]
tssPeaks <- tssPeaks[!is.na(tssPeaks)]
egfrTargetPeaks <- peakMat[tssPeaks,]
# egfrTargetPeakScaledSum <- colSums(t(scale(t(egfrTargetPeaks))))
egfrTargetPeakScaledSum <- colSums(egfrTargetPeaks)
umapEmbedding <- getEmbedding(archProj, embedding="UMAP_cor")
colnames(umapEmbedding) <- paste0("UMAP",1:2)
umapEmbedding$egfrTargetScaledSum <- egfrTargetPeakScaledSum
pEgfrTargets <- ggplot(umapEmbedding, aes(x=UMAP1,
y=UMAP2,
col=egfrTargetScaledSum)) +
theme_classic() +
geom_point() +
scale_color_gradientn(colors=wesanderson::wes_palette("Zissou1", n=100, type="continuous"))
pEgfrTargets

Check accessibility of peaks containining Ets TFBS motif
motifMatches <- readRDS(archProj@peakAnnotation$Motif$Matches)
etsMotifId <- grep(x=colnames(motifMatches), pattern="Ets")
etsMotifs <- grep(x=colnames(motifMatches), pattern="Ets", value=TRUE)
peaksWithEtsMotifs <- which(rowSums(assays(motifMatches[,etsMotifs])$matches) > 0)
length(peaksWithEtsMotifs)
## [1] 10594
umapEmbedding$etsMotifPeaks <- colSums(peakMat[peaksWithEtsMotifs,])
pEtsMotifs <- ggplot(umapEmbedding, aes(x=UMAP1,
y=UMAP2,
col=etsMotifPeaks)) +
theme_classic() +
geom_point() +
scale_color_gradientn(colors=wesanderson::wes_palette("Zissou1", n=100, type="continuous"))
pEtsMotifs

Association between Egfr targets’ accessibility and Ets motif peaks’ accessibility
plot(umapEmbedding$egfrTargetScaledSum, umapEmbedding$etsMotifPeaks,
xlab = "Egfr targets' accessibility",
ylab = "Ets-motif-containing peaks' accessibility")

Gene markers for (sub)hybrid clusters
plotEmbedding(ArchRProj = archProj, colorBy = "cellColData",
name = "predAnn", embedding = "UMAP_cor")
## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-10511521f7928-Date-2021-10-22_Time-11-18-13.log
## If there is an issue, please report to github with logFile!
## Getting UMAP Embedding
## ColorBy = cellColData
## Plotting Embedding
## 1
## ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-10511521f7928-Date-2021-10-22_Time-11-18-13.log

## get ArchR gene markers for motif enrichment
markerGenes_subHybrid <- getMarkerFeatures(
ArchRProj = archProj,
useMatrix = "GeneScoreMatrix",
groupBy = "predAnn",
bias = c("TSSEnrichment", "log10(nFrags)"),
testMethod = "wilcoxon")
## ArchR logging to : ArchRLogs/ArchR-getMarkerFeatures-105114351803c-Date-2021-10-22_Time-11-18-15.log
## If there is an issue, please report to github with logFile!
## MatrixClass = Sparse.Double.Matrix
## 2021-10-22 11:18:15 : Matching Known Biases, 0.001 mins elapsed.
## 2021-10-22 11:18:16 : Computing Pairwise Tests (1 of 5), 0.02 mins elapsed.
## 2021-10-22 11:18:37 : Computing Pairwise Tests (2 of 5), 0.371 mins elapsed.
## 2021-10-22 11:19:01 : Computing Pairwise Tests (3 of 5), 0.768 mins elapsed.
## 2021-10-22 11:19:23 : Computing Pairwise Tests (4 of 5), 1.128 mins elapsed.
## 2021-10-22 11:19:42 : Computing Pairwise Tests (5 of 5), 1.454 mins elapsed.
## ###########
## 2021-10-22 11:20:03 : Completed Pairwise Tests, 1.79 mins elapsed.
## ###########
## ArchR logging successful to : ArchRLogs/ArchR-getMarkerFeatures-105114351803c-Date-2021-10-22_Time-11-18-15.log
geneMarkers_subHybrid <- getMarkers(markerGenes_subHybrid,
cutOff = "FDR <= 0.01 & Log2FC >= 1.25")
write.csv(geneMarkers_subHybrid$C2_Hybrid, file="../data/scATAC/markerGenesHybrid.csv")
write.csv(geneMarkers_subHybrid$hybrid1, file="../data/scATAC/markerGenesHybrid1.csv")
write.csv(geneMarkers_subHybrid$hybrid2, file="../data/scATAC/markerGenesHybrid2.csv")
write.csv(geneMarkers_subHybrid$C1_Inj, file="../data/scATAC/markerGenesInjured.csv")
write.csv(geneMarkers_subHybrid$resting, file="../data/scATAC/markerGenesResting.csv")
Marker genes for hybrid1
markerGenesHybrid1 <- geneMarkers_subHybrid$hybrid1$name[1:18]
p <- plotEmbedding(
ArchRProj = archProj,
colorBy = "GeneScoreMatrix",
name = markerGenesHybrid1,
embedding = "UMAP_cor",
quantCut = c(0.01, 0.95),
size=1/3,
plotAs="points"
)
## Getting ImputeWeights
## No imputeWeights found, returning NULL
## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-1051151ca2bc5-Date-2021-10-22_Time-11-20-03.log
## If there is an issue, please report to github with logFile!
## Getting UMAP Embedding
## ColorBy = GeneScoreMatrix
## Getting Matrix Values...
## 2021-10-22 11:20:03 :
## 1 2 3 4 5 6
## Plotting Embedding
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-1051151ca2bc5-Date-2021-10-22_Time-11-20-03.log
# clean
p2Hybrid1 <- lapply(p, function(x){
x + guides(color = FALSE, fill = FALSE) +
theme_ArchR(baseSize = 6.5) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm")) +
theme(
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()
)
})
cowplot::plot_grid(plotlist=p2Hybrid1[1:9])

cowplot::plot_grid(plotlist=p2Hybrid1[10:18])

Marker genes for hybrid2
markerGenesHybrid2 <- geneMarkers_subHybrid$hybrid2$name[1:18]
p <- plotEmbedding(
ArchRProj = archProj,
colorBy = "GeneScoreMatrix",
name = markerGenesHybrid2,
embedding = "UMAP_cor",
quantCut = c(0.01, 0.95),
size=1/3,
plotAs="points"
)
## Getting ImputeWeights
## No imputeWeights found, returning NULL
## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-105113eadff98-Date-2021-10-22_Time-11-20-24.log
## If there is an issue, please report to github with logFile!
## Getting UMAP Embedding
## ColorBy = GeneScoreMatrix
## Getting Matrix Values...
## 2021-10-22 11:20:25 :
## 1 2 3 4 5 6
## Plotting Embedding
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-105113eadff98-Date-2021-10-22_Time-11-20-24.log
# clean
p2Hybrid2 <- lapply(p, function(x){
x + guides(color = FALSE, fill = FALSE) +
theme_ArchR(baseSize = 6.5) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm")) +
theme(
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()
)
})
cowplot::plot_grid(plotlist=p2Hybrid2[1:9])

cowplot::plot_grid(plotlist=p2Hybrid2[10:18])

Marker genes for other hybrid cells
markerGenesHybrid <- geneMarkers_subHybrid$C2_Hybrid$name[1:18]
p <- plotEmbedding(
ArchRProj = archProj,
colorBy = "GeneScoreMatrix",
name = markerGenesHybrid,
embedding = "UMAP_cor",
quantCut = c(0.01, 0.95),
size=1/3,
plotAs="points"
)
## Getting ImputeWeights
## No imputeWeights found, returning NULL
## ArchR logging to : ArchRLogs/ArchR-plotEmbedding-105111f04b5cf-Date-2021-10-22_Time-11-20-44.log
## If there is an issue, please report to github with logFile!
## Getting UMAP Embedding
## ColorBy = GeneScoreMatrix
## Getting Matrix Values...
## 2021-10-22 11:20:45 :
## 1 2 3 4 5 6
## Plotting Embedding
## 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
## ArchR logging successful to : ArchRLogs/ArchR-plotEmbedding-105111f04b5cf-Date-2021-10-22_Time-11-20-44.log
# clean
p2Hybrid <- lapply(p, function(x){
x + guides(color = FALSE, fill = FALSE) +
theme_ArchR(baseSize = 6.5) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm")) +
theme(
axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()
)
})
cowplot::plot_grid(plotlist=p2Hybrid[1:9])

cowplot::plot_grid(plotlist=p2Hybrid[10:18])
